package com.binarytree;

public class Solution33 {
    TreeNode pre;
    public TreeNode convertBST(TreeNode root) {
        if (root == null) return null;

        root.right = convertBST(root.right);

        if (pre != null) root.val += pre.val;
        pre = root;

        root.left = convertBST(root.left);
        return root;
    }

}
